package edu.sctu.zcy.month201505.day20150525.polymorphicdemo;

/**
 * Created by user24 on 2015/5/25.
 */
public class MainABCD {

    public static void main(String[] args) {

        A a1 = new A();
        A a2 = new B();
//        B a3 = (B) new A();
        B b = new B();
        C c = new C();
        D d = new D();


        System.out.println(a1.show(a1));//A
        System.out.println(a1.show(a2));//A

//        System.out.println(a1.show(a3));//A+B

        System.out.println(a1.show(b));//A
        System.out.println(a1.show(c));//A
        System.out.println(a1.show(d));//D

        System.out.println(a2.show(a1));//A+B
        System.out.println(a2.show(a2));//A+B
        System.out.println(a2.show(b));//A+B
        System.out.println(a2.show(c));//A+B
        System.out.println(a2.show(d));//D


        System.out.println(b.show(a1));//A+B
        System.out.println(b.show(a2));//A+B

        System.out.println(a1.show(a2));
        System.out.println(a2.show(a1));


    }
}
